
var MenuLayer = cc.Layer.extend({
    ctor: function () {

        this._super();
    },

    init: function() {
        this._super();

        var director = cc.director;
        var winsize = director.getWinSize();
        var centerpos = cc.p(winsize.width / 2, winsize.height / 2);
        var spritebg = cc.Sprite.create(res.HelloBG_png);
        cc.log("LOAD: " + res.HelloBG_png);
        spritebg.setPosition(centerpos);
        this.addChild(spritebg);

        cc.MenuItemFont.setFontSize(60);

        var startN = cc.Sprite.create(res.StartN_png);
        var startS = cc.Sprite.create(res.StartS_png);

        var menuItemPlay = cc.MenuItemSprite.create(
            startN,
            startS,
            null,
            this.onPlay,
            this);

        var menu = cc.Menu.create(menuItemPlay);
        menu.setPosition(centerpos);
        this.addChild(menu);


//        cc.audioEngine.preloadMusic(res.Background_ogg);
//        cc.audioEngine.preloadEffect(res.Jump_ogg);
//        cc.audioEngine.preloadEffect(res.PickUpCoin_ogg);
    },

    onPlay: function() {
        cc.log("==onplay clicked");
        var director = cc.director;
        director.runScene(new GamePlayScene());
//        director.replaceScene(new GamePlayScene());
    }
});



var MenuScene = cc.Scene.extend({
    onEnter:function () {
        this._super();
        var layer = new MenuLayer();
        layer.init();
        this.addChild(layer);
    }
});
